There are several mathematical functions that can be used within an EbsScript:
Name |
Purpose |
Arguments |
Return value |
Example |
abs |
Absolute value |
1: INTEGER or REAL: |
INTEGER or REAL |
abs ( -3.7 ); results in 3.7 |
acos |
Arc cosine |
1: REAL: |
REAL |
acos(0); results in 1.570796 |
asin |
Arc sine |
1: REAL: |
REAL |
asin(1); results in 1.570796 |
atan |
Arc tangent |
1: REAL: |
REAL |
atan(1); results in 0.785398 |
atof |
Converts string in real number |
1: STRING: |
REAL |
atof ("-12.34"); |
atoi |
Converts string in whole number |
1: STRING: |
INTEGER |
atoi ("-12"); results in -12 |
ceil |
Ceiling (next higher integer) |
1: REAL: |
REAL |
ceil(-1.23); results in -1 |
cos |
Cosine |
1: REAL: |
REAL |
cos(0); results in 1 |
exp |
Exponent (natural) |
1: REAL: |
REAL |
exp(1); results in 2.718282 |
finite |
checks whether a real variable has a valid finite value. This function allows to determine invalid real values as well as results of a division by zero. |
1: REAL: |
BOOLEAN |
var r1,r2:real; begin enableRealDivByZeroException(false); r1:=0.0; r2:=1.0/r1; if (finite(r2)) then begin println ("r2 is finite"); end else begin println ("r2 is not finite"); end; end. |
floor |
Floor (next lower integer) |
1: REAL: |
REAL |
floor(-1.23); results in -2 |
frac | returns the decimal part of a real number, with the same sign as that of "arg" | 1: REAL: | REAL | frac (5.67); results in 0.67 |
isnan |
checks whether a real variable has a value of "NaN" (not a number). Note that the result of a division by 0 is not NaN. To check for such a result, please use the function "finite". |
1: REAL: |
BOOLEAN |
var r1,r2:real; begin enableRealDivByZeroException(false); r1:=-1.0; r2:=pow (r1,0.5); if (isnan(r1)) then begin println ("r1 is NaN"); end else begin println ("r1 is not NaN"); end; end. |
Log |
Natural logarithm |
1: REAL: |
REAL |
log(10); results in 2.302585 |
Log10 |
10-based logarithm |
1: REAL: |
REAL |
log10(10); results in 1 |
max |
Maximum |
1: INTEGER or REAL: 2: INTEGER or REAL: |
INTEGER or REAL |
max(-4.2, -3); results in -3 |
min |
Minimum |
1: INTEGER or REAL: 2: INTEGER or REAL: |
INTEGER or REAL |
min(-4.2, -3); |
pow |
Potency |
1: REAL: (Basis) |
REAL |
pow(2, 0.3333) results in 1.259892 |
rand |
Random number |
- |
INTEGER: any number between 0 and 32767 (including) |
r:=rand; |
round |
Round |
1: REAL: |
REAL |
round(-4.46) results in -4.0 |
sin |
Sine |
1: REAL: |
REAL |
sin(0.25*3.141593); results in 0.707107 |
sqrt |
Square root |
1: REAL: |
REAL |
sqrt(3); results in 1.732051 |
tan |
Tangent |
1: REAL: |
REAL |
tan(0.25*3.141593); results in 1 |
trunc | returns the integer part of a real number, with the same sign as that of "arg" | 1: REAL: | REAL | frac (-5.67); results in -5.00 |